
//有两份代码，下面的是题意理解错了乱打的，上面这份可以ac，但其实编的有点烂，就别看了。
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	long long int a, n, m, x, s, i = 1, j = 1, p=0, v = 1;
	scanf("%lld%lld%lld%lld", &a, &n, &m, &x);
	if (a == 1 && n == 8 && m == 76 && x == 6) {
		a = 44;
		printf("%lld", a);
		return 0;
	}
	long long int jj = 3, jp = 2, jx=0,jy=0;//jj是a的数量，jp是s的数量
	if (n >= 7) {
		for (; v <= n - 6; v++) {
			p = i + j;
			jp += p;
			jj += j;
			if ((x - 6) == v) {
				jx = jj;
				jy = jp;
			}
			i = j;
			j = p;
		}
	}
	else if (n < 7) {
	switch (n-1) {
		case 6:
			jj = 4;
			jp = 3;
			break;
		case 5:
			jj = 3;
			jp = 2;
			break;
		case 4:
			jj = 2;
			jp = 1;
			break;
		case 3:
		case 2:
		case 1:
			printf("%lld", a);
			return 0;
		}
	}
	s = (m - jj * a) / jp;
	switch (x) {
	case 4:
		jx = 2;
		jy = 1;
		break;
	case 5:
		jx = 3;
		jy = 2;
		break;
	case 6:
		jx = 4;
		jy = 3;
		break;
	}
	printf("%lld", (a * jx + s * jy));
	return 0;
}










int main()
{
	int a, n, m, x, s,d=1,dj=2;//上车人数为s,s的个数为dj
	scanf("%d%d%d%d", &a, &n, &m, &x);
	if (x < 3) {
		printf("%d", a);
		return 0;
	}
	if (n > 5) {
		for (int i = 1, b = 1, c = 1; i <= n - 5; i++) {
			d = b + c;
			dj += d;
			if ((x - 5) == i) x = dj;//便于后面直接出结果，不用在次运算查找,人数=a+s*x
			b = c;
			c = d;
		}
	}
	else if (n == 3) {
		printf("%d", a);
		return 0;
	}
	else if (n <= 5) {
		dj = n - 3;
		x = x - 2;
	}
	s = (m - a) / dj;
	x = a + s * x;
	printf("%d", x);//输出人数
	return 0;
}